﻿package com.athena.process
{
	import com.greensock.motionPaths.MotionPath;
	import flash.display.*;
	import flash.utils.*;
	import flash.text.TextFormat;
	import flash.events.*;
	import com.adobe.serialization.json.JSON;
	/**
	 * ...
	 * @author ...
	 */
	public class ChatFunction 
	{
		public static var chatTimer:Timer = new Timer(1000) ; //Dieu khien chat
		public static var chatTimer1:Timer = new Timer(1000);//Dieu khien dong ho chay
		public static var chatTimer2:Timer = new Timer(1000);//Dieu khien dong ho chay		
		
		public static var TypeChat : int = 1 ;
		public static var TypeChatTable : int = 1 ;
		public static var preChat : String = "" ;
		
		public static function ChatGame_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.Game_txt.visible = true ;
			//Cocaro.mainStage_mc.Chat_mc.Group_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;			
			Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.gotoAndStop(2) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			TypeChat = 2 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Game" ;
		}
		//public static function ChatGroup_Click(evt : MouseEvent) {
			//Cocaro.mainStage_mc.Chat_mc.Game_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.Group_txt.visible = true ;
			//Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.gotoAndStop(2) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
		//}
		public static function ChatWorld_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.Game_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.Group_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			TypeChat = 1 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "TG" ;
		}
		public static function ChatPrivate_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.Game_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.Group_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			TypeChat = 4 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Riêng" ;
		}
		public static function ChatAll_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.Game_txt.visible = false ;
			//Cocaro.mainStage_mc.Chat_mc.Group_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(2) ;
			TypeChat = 2 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Game" ;
		}
		
		public static function Receive_Chat() : void {
			var obj : Object = new Object() ;
			var formatText : TextFormat = new TextFormat() ;
			formatText.font = "Arial" ;
			formatText.size = 12 ;
			if (obj.T == "1") { //Game
				formatText.color = 0xFFCC00 ;
				Cocaro.mainStage_mc.Chat_mc.Game_txt.htmlText += "<font color=\"#FFCC00\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#FFCC00\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.Game_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Game_txt.maxVerticalScrollPosition ;
			} /*else if (obj.T == "2") { //Bang
				formatText.color = 0x4E8AE5 ;
				Cocaro.mainStage_mc.Chat_mc.Group_txt.htmlText += "<font color=\"#4E8AE5\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#4E8AE5\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.Group_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Group_txt.maxVerticalScrollPosition ;
			}*/ else if (obj.T == "3") { //Thegioi
				formatText.color = 0xF6EF87 ;
				Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#F6EF87\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#F6EF87\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.World_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.World_txt.maxVerticalScrollPosition ;
			} else if (obj.T == "2") { //Rieng
				formatText.color = 0xE78045 ;
				Cocaro.mainStage_mc.Chat_mc.Private_txt.htmlText += "<font color=\"#E78045\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#E78045\">" + obj.data + ":</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.Private_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Private_txt.maxVerticalScrollPosition ;
			} 
			formatText.color = 0x00FF00 ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;
		}
		/************************************** Chat Trong ban choi ****************************************************/
		public static function InitChatTime() {
			if (chatTimer.running)
				chatTimer.stop() ;
			chatTimer = new Timer(1000) ;
			chatTimer.repeatCount = 1 ;
			chatTimer.addEventListener(TimerEvent.TIMER, StartChatTimer);				
			chatTimer.start() ;
		}
		public static function StartChatTimer(evt:TimerEvent) : void { //Dem thoi gian cho moi thao tac
			if (chatTimer.currentCount == chatTimer.repeatCount) {
				chatTimer.stop() ;
			}
		}
		
		public static function ChatInTable_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatInTable_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			TypeChatTable = 2 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Bàn" ;
		}
		
		public static function ChatWorldTable_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatInTable_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			TypeChatTable = 1 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "TG" ;
		}
		
		public static function ChatPrivateTable_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatInTable_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			TypeChatTable = 4 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Riêng" ;
		}
		
		public static function ChatAllTable_Click(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.ChatInTable_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(2) ;
			TypeChatTable = 2 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Bàn" ;
		}
		public static function DisplaySelect(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = true ;
		}
		
		public static function ComboGame_Click(evt : MouseEvent) {
			TypeChat = 2 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Game" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}
		public static function ComboPrivate_Click(evt : MouseEvent) {
			TypeChat = 4 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Riêng" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}
		public static function ComboWorld_Click(evt : MouseEvent) {
			TypeChat = 1 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "TG" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}
		
		public static function DisplaySelectTable(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = true ;
		}
		
		public static function ComboGameTable_Click(evt : MouseEvent) {
			TypeChatTable = 2 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Bàn" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}
		public static function ComboPrivateTable_Click(evt : MouseEvent) {
			TypeChatTable = 4 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Riêng" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}
		public static function ComboWorldTable_Click(evt : MouseEvent) {
			TypeChatTable = 1 ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "TG" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}
		/*public static function ComboOut(evt : MouseEvent) {
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
		}*/
		public static function InitChat_OutTable() : void {
			Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.addEventListener(MouseEvent.CLICK, ChatFunction.ChatGame_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.addEventListener(MouseEvent.CLICK, ChatFunction.ChatWorld_Click) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.addEventListener(MouseEvent.CLICK, ChatFunction.ChatGroup_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.addEventListener(MouseEvent.CLICK, ChatFunction.ChatPrivate_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.addEventListener(MouseEvent.CLICK, ChatFunction.ChatAll_Click) ;
			Cocaro.mainStage_mc.Chat_mc.btnGui.addEventListener(MouseEvent.CLICK, ChatFunction.clickChatOutTable) ;
			Cocaro.mainStage_mc.Chat_mc.Chat_txt.addEventListener(KeyboardEvent.KEY_DOWN, keyDowChatOutTable) ;			
			
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Game_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.Group_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatGame_btn.gotoAndStop(1) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatGroup_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(2) ;
			
			Cocaro.mainStage_mc.Chat_mc.Private_txt.htmlText = Cocaro.htmlPrivateChat ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Private_txt.maxVerticalScrollPosition ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText = Cocaro.htmlWorldChat ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.World_txt.maxVerticalScrollPosition ;
			Cocaro.mainStage_mc.Chat_mc.Game_txt.htmlText = Cocaro.htmlGameChat ;
			Cocaro.mainStage_mc.Chat_mc.Game_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Game_txt.maxVerticalScrollPosition ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText = Cocaro.htmlAllChat ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;
			
			Cocaro.mainStage_mc.Chat_mc.Private_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.Private_txt.setStyle("upSkin", Sprite);
			Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("upSkin", Sprite);
			Cocaro.mainStage_mc.Chat_mc.World_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.World_txt.setStyle("upSkin", Sprite);
			Cocaro.mainStage_mc.Chat_mc.Game_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.Game_txt.setStyle("upSkin", Sprite);
			
			Cocaro.mainStage_mc.Chat_mc.Private_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.Game_txt.addEventListener(TextEvent.LINK, onClickName) ;
			
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Game" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.addEventListener(MouseEvent.CLICK, DisplaySelect) ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.addEventListener(MouseEvent.CLICK, ComboGame_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.addEventListener(MouseEvent.CLICK, ComboPrivate_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.addEventListener(MouseEvent.CLICK, ComboWorld_Click) ;
			//Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.addEventListener(MouseEvent.MOUSE_OUT, ComboOut) ;
			TypeChat = 2 ;
			var tfStyle:TextFormat = new TextFormat();
			tfStyle.size = 12;
			tfStyle.color = 0xFFFFFF;
			tfStyle.font = "Arial";			
			Cocaro.mainStage_mc.Chat_mc.Chat_txt.setStyle("textFormat", tfStyle);
			//Cocaro.mainStage_mc.Chat_mc.Chat_txt.border = false ;
		}
		
		public static function InitChat_InTable() : void {
			Cocaro.mainStage_mc.Chat_mc.Chat_txt.addEventListener(KeyboardEvent.KEY_DOWN, keyDowChat) ;
			Cocaro.mainStage_mc.Chat_mc.btnGui.addEventListener(MouseEvent.CLICK, clickChat) ;
			Cocaro.mainStage_mc.Chat_mc.ChatInTable_btn.addEventListener(MouseEvent.CLICK, ChatInTable_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.addEventListener(MouseEvent.CLICK, ChatWorldTable_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.addEventListener(MouseEvent.CLICK, ChatPrivateTable_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.addEventListener(MouseEvent.CLICK, ChatAllTable_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatInTable_btn.gotoAndStop(2) ;
			Cocaro.mainStage_mc.Chat_mc.ChatWorld_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.ChatAll_btn.gotoAndStop(1) ;
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.visible = true ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.setStyle("upSkin", Sprite);
			Cocaro.mainStage_mc.Chat_mc.Private_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.Private_txt.setStyle("upSkin", Sprite);
			Cocaro.mainStage_mc.Chat_mc.World_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.World_txt.setStyle("upSkin", Sprite);
			Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("focusRectSkin",Sprite);
			Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("upSkin", Sprite);
			
			Cocaro.mainStage_mc.Chat_mc.Private_txt.htmlText = Cocaro.htmlPrivateChat ;
			Cocaro.mainStage_mc.Chat_mc.Private_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Private_txt.maxVerticalScrollPosition ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText = Cocaro.htmlWorldChat ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.World_txt.maxVerticalScrollPosition ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText = Cocaro.htmlAllChat ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;
			
			Cocaro.mainStage_mc.Chat_mc.Private_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.World_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.addEventListener(TextEvent.LINK, onClickName) ;
			
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.To_txt.text = "Bàn" ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.visible = false ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Select_btn.addEventListener(MouseEvent.CLICK, DisplaySelectTable) ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Game_btn.addEventListener(MouseEvent.CLICK, ComboGameTable_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.Private_btn.addEventListener(MouseEvent.CLICK, ComboPrivateTable_Click) ;
			Cocaro.mainStage_mc.Chat_mc.ChatCombo_mc.World_btn.addEventListener(MouseEvent.CLICK, ComboWorldTable_Click) ;			
			TypeChatTable = 2 ;	
			var tfStyle:TextFormat = new TextFormat();
			tfStyle.size = 12;
			tfStyle.color = 0xFFFFFF;
			tfStyle.font = "Arial";			
			Cocaro.mainStage_mc.Chat_mc.Chat_txt.setStyle("textFormat", tfStyle);
		}
		
		public static function keyDowChatOutTable(evt : KeyboardEvent) { //Xu ly phim trong khung chat
			if (chatTimer.running) return ;
			if (evt.keyCode == 13) {
				var txtInput : String = Cocaro.mainStage_mc.Chat_mc.Chat_txt.text ;
				if (txtInput.length > 100)
					txtInput = txtInput.substring(0, 100) ;
				txtInput = BasicFunction.trim(txtInput) ;
				var TempTypeChat : int = TypeChat ;
				if (txtInput == "") return ;
				if (txtInput.length < 1) return ;
				if (txtInput.charAt(0) == "@") TempTypeChat = 4;
				if ((TempTypeChat == 1) && (Cocaro.currPlayer.VIP < 7)) {
					Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
					return ;
				}
				var object : Object = new Object() ;
				object.N = Cocaro.currPlayer.PlayerName;
				object.D = txtInput ;
				object.evt = "16";
				object.T = TempTypeChat ;
				if (TempTypeChat == 2) {
					object.G = Cocaro.GAME_ID ;
				}
				if (TempTypeChat == 4) {
					if (txtInput.charAt(0) != "@") return ;
					object.NN = txtInput.substring(1, txtInput.indexOf(" ")) ;
					object.D = txtInput.substring(txtInput.indexOf(" ") + 1, txtInput.length) ;
					preChat = "@" + object.NN + " " ;
				}
				Cocaro.mainSocket.sendService(JSON.encode(object));
				//Cocaro.tf.appendText("=>SendChat:" + JSON.encode(object)) ;
				if (TempTypeChat == 4)
					Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = preChat ;
				else {
					Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = "" ;
					preChat = "" ;
				}
				InitChatTime() ;
			}			
		}
		public static function clickChatOutTable(evt : MouseEvent) : void { //Kick Chat
			if (chatTimer.running) return ;
			var txtInput : String = Cocaro.mainStage_mc.Chat_mc.Chat_txt.text ;
			if (txtInput.length > 100)
				txtInput = txtInput.substring(0, 100) ;
			txtInput = BasicFunction.trim(txtInput) ;
			var TempTypeChat : int = TypeChat ;
			if (txtInput == "") return ;
			if (txtInput.length < 1) return ;
			if (txtInput.charAt(0) == "@") TempTypeChat = 4;
			if ((TempTypeChat == 1) && (Cocaro.currPlayer.VIP < 7)) {
				Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
				return ;
			}
			var object : Object = new Object() ;
			object.N = Cocaro.currPlayer.PlayerName;
			object.D = txtInput ;
			object.evt = "16";
			object.T = TempTypeChat ;
			if (TempTypeChat == 2) {
				object.G = Cocaro.GAME_ID ;
			}
			if (TempTypeChat == 4) {
				if (txtInput.charAt(0) != "@") return ;
				object.NN = txtInput.substring(1, txtInput.indexOf(" ")) ;
				object.D = txtInput.substring(txtInput.indexOf(" ") + 1, txtInput.length) ;
				preChat = "@" + object.NN + " " ;
			}
			Cocaro.mainSocket.sendService(JSON.encode(object));		
			//Cocaro.tf.appendText("=>SendChat:" + JSON.encode(object)) ;
			if (TempTypeChat == 4)
				Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = preChat ;
			else {
				Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = "" ;
				preChat = "" ;
			}
			InitChatTime() ;
		}
		public static function CheckChatPrivate(name : String) {
			for (var i:int = 0; i < ProcessInTable.currTable.ArrPlayers.length; i++) 
			{
				if (ProcessInTable.currTable.ArrPlayers[i].PlayerName == name) return false ;
			}
			return true ;
		}
		public static function keyDowChat(evt : KeyboardEvent) { //Xu ly phim trong khung chat
			if (chatTimer.running) return ;
			if (evt.keyCode == 13) {
				var txtInput : String = Cocaro.mainStage_mc.Chat_mc.Chat_txt.text ;
				if (txtInput.length > 100)
					txtInput = txtInput.substring(0, 100) ;
				txtInput = BasicFunction.trim(txtInput) ;
				var TempTypeChat : int = TypeChatTable ;
				if (txtInput == "") return ;
				if (txtInput.length < 1) return ;
				if (txtInput.charAt(0) == "@") TempTypeChat = 4;
				if ((TempTypeChat == 1) && (Cocaro.currPlayer.VIP < 7)) {
					Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
					return ;
				}
				var object : Object = new Object() ;
				if (TempTypeChat == 2) {
					object.Name = Cocaro.currPlayer.PlayerName;
					object.Data = txtInput ;
					object.evt = "chattable";
					Cocaro.mainSocket.sendData(JSON.encode(object));
					//Cocaro.tf.appendText("=>SendChat:" + JSON.encode(object)) ;
				} else {
					object.N = Cocaro.currPlayer.PlayerName;
					object.D = txtInput ;
					object.evt = "16";
					object.T = TempTypeChat ;
					if (TempTypeChat == 4) {
						if (txtInput.charAt(0) != "@") return ;
						object.NN = txtInput.substring(1, txtInput.indexOf(" ")) ;
						if (!CheckChatPrivate(object.NN)) {
							BasicFunction.ShowAlert("Không được chat riêng với người cùng bàn chơi!") ;
							return ;
						}
						preChat = "@" + object.NN + " " ;
						object.D = txtInput.substring(txtInput.indexOf(" ")+1, txtInput.length) ;
					}
					Cocaro.mainSocket.sendService(JSON.encode(object));		
					//Cocaro.tf.appendText("=>SendChat:" + JSON.encode(object)) ;
				}
				if (TempTypeChat == 4)
					Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = preChat ;
				else {
					Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = "" ;
					preChat = "" ;
				}
				InitChatTime() ;
			}			
		}
		public static function clickChat(evt : MouseEvent) : void { //Kick Chat
			if (chatTimer.running) return ;
			var txtInput : String = Cocaro.mainStage_mc.Chat_mc.Chat_txt.text ;
			if (txtInput.length > 100)
				txtInput = txtInput.substring(0, 100) ;
			txtInput = BasicFunction.trim(txtInput) ;
			var TempTypeChat : int = TypeChatTable ;
			if (txtInput == "") return ;
			if (txtInput.length < 1) return ;		
			if (txtInput.charAt(0) == "@") TempTypeChat = 4;
			if ((TempTypeChat == 1) && (Cocaro.currPlayer.VIP < 7)) {
				Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#FF0000\"> Bạn phải là Vip 7 trở lên mới được chat kênh TG</font>\n" ;
				return ;
			}
			var object : Object = new Object() ;
			if (TempTypeChat == 2) {
				object.Name = Cocaro.currPlayer.PlayerName;
				object.Data = txtInput ;
				object.evt = "chattable";
				Cocaro.mainSocket.sendData(JSON.encode(object));
				//Cocaro.tf.appendText("=>SendChat:" + JSON.encode(object)) ;
			} else {
				object.N = Cocaro.currPlayer.PlayerName;
				object.D = txtInput ;
				object.evt = "16";
				object.T = TempTypeChat ;
				if (TempTypeChat == 4) {
					if (txtInput.charAt(0) != "@") return ;
					object.NN = txtInput.substring(1, txtInput.indexOf(" ")) ;
					if (!CheckChatPrivate(object.NN)) {
						BasicFunction.ShowAlert("Không được chat riêng với người cùng bàn chơi!") ;
						return ;
					}
					preChat = "@" + object.NN + " " ;
					object.D = txtInput.substring(txtInput.indexOf(" ")+1, txtInput.length) ;
				}
				Cocaro.mainSocket.sendService(JSON.encode(object));		
				//Cocaro.tf.appendText("=>SendChat:" + JSON.encode(object)) ;
			}
			if (TempTypeChat == 4)
				Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = preChat ;
			else {
				Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = "" ;
				preChat = "" ;
			}
			InitChatTime() ;
		}
		
		public static function StartChat1(ev : TimerEvent) : void {
			if (Cocaro.mainStage_mc.currentFrame != 5) return ;
			if (chatTimer1.currentCount == chatTimer1.repeatCount) {
				chatTimer1.stop() ;
				Cocaro.mainStage_mc.Player1_mc.Chat_mc.visible = false ;
			}
		}
		public static function StartChat2(ev : TimerEvent) : void {
			if (Cocaro.mainStage_mc.currentFrame != 5) return ;
			if (chatTimer2.currentCount == chatTimer2.repeatCount) {
				chatTimer2.stop() ;
				Cocaro.mainStage_mc.Player2_mc.Chat_mc.visible = false ;
			}
		}
		
		public static function Chat(object : Object) : void { //Nhan thong tin chat server tra ve
			//Cocaro.tf.appendText("=>Chat:" + object.Name + "-" + object.Data);
			Cocaro.SoundMessage() ;
			////Cocaro.tf.appendText("=>Chat1:");
			//var object = JSON.decode(str) ;
			if (object.Name != Cocaro.currPlayer.PlayerName) {
				Cocaro.mainStage_mc.Chat_mc.InTable_txt.htmlText += "<font color=\"#DDDDDD\">[<a href=\"event:" + object.Name + "\">" + object.Name + "</a>]: </font><font color=\"#DDDDDD\">" + object.Data +  "</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#DDDDDD\">[<a href=\"event:" + object.Name + "\">" + object.Name + "</a>]: </font><font color=\"#DDDDDD\">" + object.Data +  "</font>\n" ;
			} else {
				Cocaro.mainStage_mc.Chat_mc.InTable_txt.htmlText += "<font color=\"#DDDDDD\">[<a href=\"event:" + object.Name + "\">" + object.Name + "</a>]: </font><font color=\"#DDDDDD\">" + object.Data +  "</font>\n" ;
				Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#DDDDDD\">[<a href=\"event:" + object.Name + "\">" + object.Name + "</a>]: </font><font color=\"#DDDDDD\">" + object.Data +  "</font>\n" ;
			}
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.addEventListener(TextEvent.LINK, onClickName) ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
			
			var myTextFormat:TextFormat = new TextFormat();
			myTextFormat.font = "Arial";
			myTextFormat.size = 13;
			myTextFormat.bold = false;
			myTextFormat.italic = false;
			myTextFormat.underline = false;
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.setStyle("textFormat", myTextFormat);
			Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("textFormat", myTextFormat);
			Cocaro.mainStage_mc.Chat_mc.InTable_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.InTable_txt.maxVerticalScrollPosition ;
			Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;
			/*Hien thi tren khung nguoi dung*/
			//Cocaro.tf.appendText("==>1");
			var cs : int = -1 ;
			for (var i:int = 0; i < ProcessInTable.currTable.ArrPlayers.length; i++) 
			{
				if (ProcessInTable.currTable.ArrPlayers[i].PlayerName == object.Name) {
					cs = i ;
					break ;					
				}
			}
			//Cocaro.tf.appendText("==>2");
			if (object.Name == ".") return;
			if (cs == -1) return ;
			//Cocaro.tf.appendText("==>" + object.Name + "-" + cs);
			var t : Boolean = false ;			
			if (object.Name != Cocaro.currPlayer.PlayerName) {
				Cocaro.mainStage_mc.Player2_mc.Chat_mc.txtChat.text = object.Data ;
				Cocaro.mainStage_mc.Player2_mc.Chat_mc.visible = true ;
				chatTimer2 = new Timer(1000) ;
				chatTimer2.repeatCount = 3 ;
				chatTimer2.addEventListener(TimerEvent.TIMER, StartChat2);
				chatTimer2.start() ;
			} else {
				Cocaro.mainStage_mc.Player1_mc.Chat_mc.txtChat.text = object.Data ;
				Cocaro.mainStage_mc.Player1_mc.Chat_mc.visible = true ;
				chatTimer1 = new Timer(1000) ;
				chatTimer1.repeatCount = 3 ;
				chatTimer1.addEventListener(TimerEvent.TIMER, StartChat1);
				chatTimer1.start() ;
			}
		}
		/******************************** Chat Out Table ******************************************/
		public static function onClickName(e:TextEvent):void {
			Cocaro.mainStage_mc.Chat_mc.Chat_txt.text = "@" + e.text + " ";
		}
		public static function ChatOutTable(obj : Object) {
			//Cocaro.tf.appendText("==>" + obj.D + "-" + obj.T) ;
			if ((obj.T != 1) && (obj.T != 2))
				Cocaro.SoundMessage() ;
			var myTextFormat:TextFormat = new TextFormat();
			myTextFormat.font = "Arial";
			myTextFormat.size = 13;
			myTextFormat.bold = false;
			myTextFormat.italic = false;
			myTextFormat.underline = false;			
			if (Cocaro.mainStage_mc.currentFrame == 5) {
				if (obj.T == 1) { //The gioi
					Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#F6EF87\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#F6EF87\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#F6EF87\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#F6EF87\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.World_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.World_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.World_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.World_txt.maxVerticalScrollPosition ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;					
				} else if (obj.T == 4) { //Rieng
					Cocaro.mainStage_mc.Chat_mc.Private_txt.htmlText += "<font color=\"#E78035\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#E78035\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#E78035\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#E78035\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.Private_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.Private_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.Private_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Private_txt.maxVerticalScrollPosition ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;					
					if (!Cocaro.mainStage_mc.Chat_mc.Private_txt.visible && !Cocaro.mainStage_mc.Chat_mc.All_txt.visible) {
						Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(3) ;
					}
				}
			} else {
				//var object = JSON.decode(str) ;
				if (obj.T == 1) { //The gioi
					Cocaro.mainStage_mc.Chat_mc.World_txt.htmlText += "<font color=\"#F6EF87\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#F6EF87\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#F6EF87\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#F6EF87\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.World_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.World_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.World_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.World_txt.maxVerticalScrollPosition ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;					
				} else if (obj.T == 2) { //Game
					Cocaro.mainStage_mc.Chat_mc.Game_txt.htmlText += "<font color=\"#FFCC00\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#FFCC00\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#FFCC00\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#FFCC00\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.Game_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.Game_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.Game_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Game_txt.maxVerticalScrollPosition ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;					
				} else if (obj.T == 4) { //Rieng
					Cocaro.mainStage_mc.Chat_mc.Private_txt.htmlText += "<font color=\"#E78035\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#E78035\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.htmlText += "<font color=\"#E78035\">[<a href=\"event:" + obj.N + "\">" + obj.N + "</a>]: </font><font color=\"#E78035\">" + obj.D +  "</font>\n" ;
					Cocaro.mainStage_mc.Chat_mc.Private_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.addEventListener(TextEvent.LINK, onClickName) ;
					Cocaro.mainStage_mc.Chat_mc.Private_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.All_txt.setStyle("textFormat", myTextFormat);
					Cocaro.mainStage_mc.Chat_mc.Private_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.Private_txt.maxVerticalScrollPosition ;
					Cocaro.mainStage_mc.Chat_mc.All_txt.verticalScrollPosition = Cocaro.mainStage_mc.Chat_mc.All_txt.maxVerticalScrollPosition ;					
					if (!Cocaro.mainStage_mc.Chat_mc.Private_txt.visible && !Cocaro.mainStage_mc.Chat_mc.All_txt.visible) {
						Cocaro.mainStage_mc.Chat_mc.ChatPrivate_btn.gotoAndStop(3) ;
					}
				}
			}
		}
	}
}